package com.lb.uts.web;

import com.lb.uts.constants.UTSConstants;
import com.lb.uts.service.IActiveSchedulingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.stereotype.Component;

/**
 * 监听调度器销毁消息
 *
 * @author liangb
 * @version 3.0
 * @date 2019/5/6 11:39
 */
@Component
public class UtsApplicationDestroy implements ApplicationListener<ContextClosedEvent> {

    @Autowired
    private IActiveSchedulingService activeSchedulingService;

    @Override
    public void onApplicationEvent(ContextClosedEvent event) {
        activeSchedulingService.deleteByIp(UTSConstants.LOCAL_IP_PORT);
    }
}
